package stableproject;

import java.util.ArrayList;

public class NodeBank {
	ArrayList<Node> bank;

	public NodeBank() {
		bank = new ArrayList<Node>();
	}

	/**
	 * Add a node which represents a class to the bank
	 * 
	 * @param n
	 */
	public void addNode(Node n) {
		bank.add(n);
	}

	/**
	 * Print all the information related to the imported files
	 */
	public void printAll() {
		for (Node n : bank) {

			System.out.println("Filename: " + n.getFilename());
			System.out.println("Classname: " + n.name);
			System.out.println("Method Count: " + n.methodHash.keySet().size());
			System.out.println("Method List: " + n.methodHash.keySet());
			System.out
					.println("Public Method Count: " + n.publicMethods.size());
			System.out.println("Public Methods: " + n.publicMethods);
			System.out.println("Comment Count: " + n.getCommentCount());
			System.out.println("Depth of Inheritance " + n.getDIT());
			System.out.println("Extends: " + n.extendz);
			System.out.println("Number of Children " + n.noKids);
			System.out.println("Parameters " + n.methodHash);
			System.out.println("Number of Lines in Class: "
					+ n.compUnit.getEndLine());
			System.out.println("Parameter Count: ");
			n.printParamList();
			System.out.println("\r");
		}

	}

	/**
	 * Takes a class and returns the class this node extends
	 * 
	 * @param classname
	 * @return
	 */
	public String getExendsList(String classname) {
		for (Node n : bank)
			if (n.getClassName().matches(classname))
				return n.getExtends();

		return null;
	}

	/**
	 * Determines whether a class exists in the bank
	 * 
	 * @param leaf
	 * @return
	 */
	public boolean hasClass(String leaf) {

		if (leaf == null || leaf.matches(""))
			return false;

		for (Node n : bank)
			if (n.name.matches(leaf))
				return true;

		return false;
	}

}
